/*package com.mycompany.encryption;

import java.net.URLDecoder;
import java.net.URLEncoder;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEParameterSpec;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.broadleafcommerce.common.config.RuntimeEnvironmentKeyResolver;
import org.broadleafcommerce.common.config.SystemPropertyRuntimeEnvironmentKeyResolver;
import org.broadleafcommerce.common.encryption.EncryptionModule;
import org.broadleafcommerce.common.encryption.PassthroughEncryptionModule;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;


//@Component
@Service("blEncryptionModule")
public class EncryptionModuleImpl extends PassthroughEncryptionModule {
	
	


	private static Cipher encryptCipher;
	private static Cipher decryptCipher;
	private static sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
	private static sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();

	private static final String CHARSET = "UTF-8";
	private static final String DEFAULTENCRYPTIONPASSWORD = "MOHITDUFHQWER98234QWE378AHASDF93HASDF9238HAJSDF923";
	private static final byte[] DEFAULTSALT = {

		(byte) 0xa3, (byte) 0x21, (byte) 0x24, (byte) 0x2c,

		(byte) 0xf2, (byte) 0xd2, (byte) 0x3e, (byte) 0x19 };

	
protected static final Logger LOG = LogManager.getLogger(EncryptionModuleImpl.class);
protected RuntimeEnvironmentKeyResolver keyResolver = new SystemPropertyRuntimeEnvironmentKeyResolver();
    
		public EncryptionModuleImpl(){
			if ("production".equals(keyResolver.resolveRuntimeEnvironmentKey())) {
	            LOG.warn("This passthrough encryption module provides NO ENCRYPTION and should NOT be used in production.");
	        }
		}
    
    

    public String decrypt(String cipherText) throws SecurityException {
    	try {

			setupEncryptor(DEFAULTENCRYPTIONPASSWORD, DEFAULTSALT);

			byte[] dec = decoder.decodeBuffer(URLDecoder.decode(cipherText,CHARSET));
			byte[] utf8 = decryptCipher.doFinal(dec);

			return new String(utf8, CHARSET);

		} catch (Exception e) {
			throw new SecurityException("Could not decrypt: " + e.getMessage());
		}
	
      //  return cipherText;
    }
    

    public  String encrypt(String plainText) throws SecurityException {
    	try {
    		System.out.println("EncryptionModule.encrypt()");
			setupEncryptor(DEFAULTENCRYPTIONPASSWORD, DEFAULTSALT);

			byte[] utf8 = plainText.getBytes(CHARSET);

			byte[] enc = encryptCipher.doFinal(utf8);

			return URLEncoder.encode(encoder.encode(enc),CHARSET);
		}

		catch (Exception e)

		{
			throw new SecurityException("Could not encrypt: " + e.getMessage());
		}
	
    	
       // return plainText;
    }
    private static void setupEncryptor(String defaultEncryptionPassword, byte[] salt) {

		java.security.Security.addProvider(new com.sun.crypto.provider.SunJCE());

		char[] pass = defaultEncryptionPassword.toCharArray();

		int iterations = 3;

		init(pass, salt, iterations);
	}
    public static void init(char[] pass, byte[] salt, int iterations) throws SecurityException {
		try {
			PBEParameterSpec ps = new javax.crypto.spec.PBEParameterSpec(salt, 20);

			SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");

			SecretKey k = kf.generateSecret(new javax.crypto.spec.PBEKeySpec(pass));

			encryptCipher = Cipher.getInstance("PBEWithMD5AndDES/CBC/PKCS5Padding");

			encryptCipher.init(Cipher.ENCRYPT_MODE, k, ps);

			decryptCipher = Cipher.getInstance("PBEWithMD5AndDES/CBC/PKCS5Padding");

			decryptCipher.init(Cipher.DECRYPT_MODE, k, ps);
		} catch (Exception e) {
			throw new SecurityException("Could not initialize CryptoLibrary: " + e.getMessage());
		}
	}

}
*/